package com.atguigu.gmall.realtime.common.function;

import com.atguigu.gmall.realtime.common.util.IkUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public class SplitWordFunction extends TableFunction<Row> {
    public void eval(String keyword){
        // 调用Ikutil进行分词操作
        List<String> words = IkUtil.splitWord(keyword);


        for (String word : words){
            collect(Row.of(word));
        }
    }

}
